<?php
/** 
 * <pre>
 * DiabloStudios.Board v1.0
 * 
 * Template fetch class
 * </pre>
 * 
 * @copyright	(c) 2010 DiabloStudios
 * @license		GNU Affero GPL v3 or newer
 * @package		PHP-Fusion
 * @subpackage	DiabloStudios.Board
 * @link		http://diablostudios.pl
 * @version     $Id: templates.php 1 2011-03-20 11:56:30Z Bartek $
 */
class templates { 
    
    /** 
     * Variable that stores the templates path
     * 
     * @var string
     */
    var $tpl_path;
    
    /**
	 * Gets templates.
	 *
	 * @param string The title of the template to get.
	 * @param boolean True if template contents must be escaped, false if not.
	 * @param boolean True to output HTML comments, false to not output.
	 * @return string The template HTML.
	 */
    function get($title,$eslashes=1,$htmlcomments=1) {
        
        global $dsb;
        
        $template = @file_get_contents($this->tpl_path.$title.".tpl"); 
         
        if (!$template)
        {
            $dsb->trigger_dsb_error("Szablon nie odnaleziony","Nie znaleziono szablonu '{$title}.tpl' w folderze {$this->tpl_path}");
            die();
           
        }  
        if($htmlcomments)
		{
			if($dsb->settings['tplhtmlcomments'] == 1)
			{
				$template = "<!-- start: ".htmlspecialchars_uni($title)." -->\n{$template}\n<!-- end: ".htmlspecialchars_uni($title)." -->";
			}
			else
			{
				$template = "\n{$template}\n";
			}
		}
        
        if($eslashes)
		{
			$template = str_replace("\\'", "'", addslashes($template));
		}
		return $template;        
    }
}

?>